package com.bjpowernode.controller;


import com.bjpowernode.domain.User;
import com.bjpowernode.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@Controller
public class UserController {

    @Resource
    private UserService userService;
    /*获取账户和密码，验证是否正确*/
    @RequestMapping("/controller.do")
    public String check(HttpSession session, User user, HttpServletResponse response){
        System.out.println("hahaha##############");
        User user1 = userService.findUser(user);
        ModelAndView mv = new ModelAndView();
        if(user1 != null){//验证成功
            session.setAttribute("role",user1.getUsername());
            System.out.println("zheng");
           return "redirect:index.html";
        }else{//验证失败

            return "redirect:/index.html";
        }


    }
}
